classdef Neuron < handle
    
    
    
    
    properties
        
        SynapsesDendrite
        SynapsesAxon
        
        FireThreshold
        ChargeValue
        
    end
    
    properties (GetAccess = public, SetAccess = private)
        
        % in neuron fired we mark it for processing
        ToProcess
        
        % when a neuron fires increase the strength of these synapses
        SynapticFireHistoryIncCount
        
        % when a neuron fires decrease the strength of these synapses
        SynapticFireHistoryDecCount
        
    end
    
    methods
        
        % constructor
        function obj = Neuron(fireThreshold, synapticFireHistoryIncCount, synapticFireHistoryDecCount)
            obj.FireThreshold = fireThreshold;
            
            obj.SynapticFireHistoryIncCount = synapticFireHistoryIncCount;
            obj.SynapticFireHistoryDecCount = synapticFireHistoryDecCount;
        end
        
        % function that a dendrite will call when an SynapseAxon fires
        function fired = IncreaseCharge(obj, value)
            fired = false;
            
            % determine if the neuron fired
            obj.ChargeValue = obj.ChargeValue + value;
            if obj.ChargeValue >= obj.FireThreshold
                fired = true;
                obj.ChargeValue = 0;
                obj.ToProcess = true;
            end
        end
        
    end
    
end

